---
title: NextDrupal Client
excerpt: A powerful JSON:API client for Drupal.
---

The `NextDrupal` client is a powerful JSON:API client that ships with helpers for working with Drupal data.

You can use the `NextDrupal` client to fetch JSON:API data from Drupal to build static pages in advance, or server render pages on-demand.

It also comes with full support for JSON:API write operations which means you can create JSON:API resources from Next.js to Drupal.

---

## Features

1. Customizable JSON:API client for data fetching.
2. Helpers for fetching resources, menus, views and search indices.
3. Helpers for JSON:API write operations (POST, PATCH, and DELETE)
4. Support for custom auth (`Bearer`, `Basic`, `Next-Auth` or bring your own).
5. Support for custom serializers.
6. Support for custom fetcher.
7. Support for cached resources (memory cache, redis...etc).
8. Human-readable error messages.

---

## Usage

### App Router

```ts
import { NextDrupal } from "next-drupal"

// Create a new NextDrupal client.
const drupal = new NextDrupal("https://example.com")

// Fetch articles.
const articles = await drupal.getResourceCollection("node--article")

// Fetch one article by id.
const article = await drupal.getResource(
  "node--article",
  "f4c61473-8297-4bf3-bab7-21c9633a7ca7"
)
```

### Pages Router

```ts
import { NextDrupalPages } from "next-drupal"

// Create a new DrupalClient.
const drupal = new NextDrupalPages("https://example.com")

// Fetch articles.
const articles = await drupal.getResourceCollection("node--article")

// Fetch one article by id.
const article = await drupal.getResource(
  "node--article",
  "f4c61473-8297-4bf3-bab7-21c9633a7ca7"
)
```
